// 手机号
export const phone = (that) => {
  return [
    {
      required: true,
      message: '请输入手机号',
      trigger: ['change', 'blur']
    },
    {
      validator: (rule, value, callback) => {
        return that.$u.test.mobile(value)
      },
      message: '手机号码不正确',
      trigger: ['change', 'blur']
    }
  ]
}
// 验证码
export const sms = [
  {
    required: true,
    message: '请输入验证码',
    trigger: ['change', 'blur']
  },
  {
    type: 'number',
    message: '验证码只能为数字',
    trigger: ['change', 'blur']
  }
]
// 密码
export const password = (msg) => {
  return [
    {
      required: true,
      message: msg || '请输入密码',
      trigger: ['change', 'blur']
    },
    {
      pattern: /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]+\S{5,18}$/,
      message: '密码需同时含有字母和数字，长度在6-18位之间',
      trigger: ['change', 'blur']
    }
  ]
}
// 确认密码
export const rePassword = (that) => {
  return [
    {
      required: true,
      message: '请确认新密码',
      trigger: ['change', 'blur']
    },
    {
      validator: (rule, value, callback) => {
        console.log(that.pwdForm.newPwd)
        return value === that.pwdForm.newPwd
      },
      message: '两次输入的密码不一样',
      trigger: ['change', 'blur']
    }
  ]
}
